 begintalkscript;

 variables;

 short j;

		///***Havelock***///

 begintalknode 1;
	state = -1;
	nextstate = 1;
	question = "Havelock";
	text1 = "Surprisingly, the hut is inhabited. An old man with a short, possibly burnt, beard is pacing back and forth of the hut, mumbling now and then. The man is wearing wizard's robes, though they are extremely worn and a bit tattered.";
	text2 = "The man's skin is incredibly gray. It's like he hasn't been outside for years. You try to get his attention and ask the man's name. You receive a mumble: _Mmm, can't be bothered, such nonsense ...Mmm... Havelock! Yes, that's it!_";
	text5 = "You have no idea what the wizard is doing right now.";
	text6 = "You can't shake the feeling there is something very strange about Havelock.";
	action = INTRO;
	code = if ((get_flag(10,4) != 1) && (get_flag(10,6) != 1)) 
			remove_string(6);
 break;

 begintalknode 2;
	state = 1;
	nextstate = 7;
	question = "Are you a wizard?";
	text1 = "_Mmm... I'm an, alchemist._ The man looks at his tattered robes. _Maybe I was a wizard once, also._";

 begintalknode 3;
	state = 1;
	nextstate = 2;
	question = "What are you doing?";
	text1 = "_Making gold, or at least, I'm trying to. It is not an easy task, I've tried it for years and so far I've only had a few, accidents, or was that many accidents?_";

 begintalknode 4;
	state = 2;
	nextstate = 3;
	question = "What kind of accidents?";
	text1 = "_Well, the most recent one was an explosion that caught my beard on fire. It's mostly just explosions... mmm ... but, I did try to make gold out of a steel plate mail once. I can't quite remember what I did to it, but it didn't turn into gold!_";
	text2 = "_Frustrated, I banged the armor with my hammer, only to receive a strong magical shock. I believe I somehow enchanted the armor to zap its attacker._";
	code = if (get_flag(10,6) != 2)
		set_flag(10,6,1);
 break;

 begintalknode 5;
	state = 3;
	nextstate = 4;
	question = "Do you still have that armor? Perhaps you could give it to me?";
	text1 = "_I still have it, but I'm not going to give it to you. I will, however, sell it to you and some other things I accidentally created over the years. I'm going to need the money when I run out of supplies._";

 begintalknode 6;
	state = 4;
	nextstate = -1;
	question = "All right, show me what you have.";
	text1 = "_Now, unless you want something else, I need to get back to work_";
	action = SET_SDF 10 5 1;
	code = begin_shop_mode("Havelock's Emporium","Havelock has accidentally created several powerful items in the course of years. Unfortunately he won't part with the cheaply.",9,6,-1);
		set_flag(10,5,1);
 break;

 begintalknode 7;
	state = 2;
	nextstate = -1;
	question = "Why do you want to make gold?";
	text1 = "The old man seems bewildered by the question. _Why? I ask you, why not? Why wouldn't I want to have endless supply of gold?_";

 begintalknode 8;
	state = 1;
	nextstate = 5;
	condition = get_flag(10,0) == 1 && get_flag(10,1) != 2;
	question = "I heard you have a secret passage to the valley east of here.";
	text1 = "_A passage?_ It takes a moment for Havelock to concentrate. _You must mean my mandrake caverns. Yes I seem to recall there being a way to the surface. So you want to use it? Well I don't see why I would, unless you want to do a favor for me?_";

 begintalknode 9;
	state = 5;
	nextstate = -1;
	condition = has_special_item(5) == 0;
	question = "Old man, we are working for the Empire. It is essential for our quest that you let us past!";
	text1 = "Havelock seems unimpressed. _Too bad, I guess we have no deal then._";

 begintalknode 10;
	state = 5;
	nextstate = -1;
	condition = has_special_item(5) == 1;
	question = "We have been deputized by the Chief Empire liaison of this area, you must let us past!";
	text1 = "_Mm, so you're some kind of important fellows then? Hmm... maybe I should ask for more._";

 begintalknode 11;
	state = 5;
	nextstate = 6;
	question = "What do you want?";
	text1 = "_I have gathered several alchemical ingredients over the years, but I have managed to scry the locations of two items that I wish to examine, in order to see if they are of use to me._";
	text2 = "_One of them is in the middle of a swamp somewhere south of here, and the other is also south of here in some caverns. Just bring me either one of them._";
	action = SET_SDF 10 1 1;

 begintalknode 12;
	state = 6;
	nextstate = -1;
	question = "Exactly what am I looking for?";
	text1 = "_The first is a very special type of toadstool, known as Borgia toadstools, the second is in fact a creature. A white screaming bat to be precise. Bring me its head or some other important piece._";

 begintalknode 13;
	state = 11;
	nextstate = -1;
	condition = has_item(454);
	question = "You got yourself a deal Havelock.";
	text1 = "Havelock teaches you about nature lore. Then he takes the toadstools and disappears into his backroom. He comes back with a few items. _Here take them!_";
	action = SET_SDF 1 27 3;
	code = take_all_of_item(454);
		reward_give(240);
		reward_give(462);
		j = char_with_highest_skill(16);
		alter_stat(j,16,3);
 break;

 begintalknode 14;
	state = 1;
	nextstate = 11;
	condition = get_flag(10,1) == 2 && has_item(454);
	question = "I found some Borgia Toadstools. You wouldn't need some, would you?";
	text1 = "The wizard inspects the toadstools. _Yes! Wonderful! Hand them over. Mmm... I see you want something in return. Well I have some items I could part with. They weren't of any use._";
	text2 = "_Hmm... Let's see... I suppose you could have the graymold salve and that weird powder. Yes! That's useless enough! And mmm... I suppose I could teach you something about nature. You could find that useful._";


 begintalknode 15;
	state = 1;
	nextstate = 11;
	condition = has_special_item(6) && get_flag(10,1) == 2;
	question = "Do you still need this bat head?";
	text1 = "The wizard grins blissfully. _Yes! Wonderful! Hand it over. Mmm... I see you want something in return. Well I have some items I could part with. They weren't of any use._";
	text2 = "_Hmm... Let's see... I suppose you could have the graymold salve and that weird powder. Yes! That's useless enough! And mmm... I suppose I could teach you something about nature. You could find that useful._";
	action = SET_SDF 1 27 3;


 begintalknode 16;
	state = 1;
	nextstate = 8;
	condition = get_flag(10,1) == 1 && has_item(454);
	question = "Here is the Borgia Toadstools, now let me pass.";
	text1 = "The old man takes the toadstools. _Mmm... perhaps these are the ingredients I need. Now as for you._ Havelock reaches into his robes and eventually pulls out a tiny brass key. _It will disable the magical enchantments I placed on the door._";
	text2 = "_Just don't let any of the ...mmm... creatures upstairs._";
	code = change_spec_item(7,1);
		set_flag(10,1,2);
		take_all_of_item(454);
 break;

 begintalknode 17;
	state = 1;
	nextstate = 8;
	condition = get_flag(10,1) == 1 && has_special_item(6);
	question = "Is this the bat head you wanted?";
	text1 = "_Indeed it is! Let me have it!_ The old man eagerly takes the head and then reaches into his robes and eventually pulls out a tiny brass key. _It will disable the magical enchantments I placed on the door._";
	text2 = "_Just don't let any of the ...mmm... creatures upstairs._";
	code = change_spec_item(7,1);
		take_special_item(6);
		set_flag(10,1,2);
 break;

 begintalknode 18;
	state = 8;
	nextstate = 1;
	question = "What creatures?";
	text1 = "_Mmm? I didn't mention that? There are, some sort of, creatures in those caverns. I, can't exactly remember which kind they are. But I did place a protective rune in there, just be sure to keep your foot on it, when you cross it._";
	text2 = "_I created it so that it zaps whatever floats above it._";

 begintalknode 19;
	state = 1;
	nextstate = -1;
	condition = (get_flag(10,5) > 0 && get_flag(10,6) != 2);
	question = "Can you show me what you've created, again?";
	text1 = "_Now, unless you want something else, I need to get back to work_";
	code = begin_shop_mode("Havelock's Emporium","Havelock has accidentally created several powerful items in the course of years. Unfortunately he won't part with the cheaply.",9,6,-1);
 break;

 begintalknode 20;
	state = 1;
	nextstate = 9;
	condition = get_flag(10,4) == 1 && get_flag(10,6) == 1;
	question = "Are you, alright?";
 	text1 = "_Of course I'm alright! Mmm, never felt better._ You take a close deeper look at Havelock. His skin is unusually gray and it's also incredibly dry and cracked. Then you notice it. He isn't breathing!";

 begintalknode 21;
	state = 9;
	nextstate = 10;
	question = "Havelock! You're not breathing!";
	text1 = "_What foolishness is this of course I'm breathing! How could I be..._ Havelock pulls his palm in front of his mouth. Then he checks his own pulse. _Well dump me in blood and toss me to the giants._";

 begintalknode 22;
	state = 10;
	nextstate = -1;
	question = "You didn't even know you were dead?";
	text1 = "_How could I have noticed? I was, still walking around and... Mmm, on the other hand I can't remember when I last ate, or slept._ A twinkle appears on Havelock's eye. _Say, I don't have to sleep or eat!_";
	text2 = "_Why this is spectacular! I don't have to interrupt my work for anything! As a token of my gratitude, I'll lower my prices for you._";
	action = SET_SDF 10 6 2;

 begintalknode 23;
	state = 10;
	nextstate = 1;
	question = "How did you die?";
	text1 = "_Mmm... it's hard to tell. There have been so many explosions. Perhaps it was that one two, or was that three years ago, the big explosion._";
	text2 = "_Right before the big explosion occurred I knew I'd made a serious blunder. After the explosion I just got up, never even thought of dying. I had to finish my work._ Well you've heard that powerful wizards are capable of cheating death.";
	text3 = "But this is the first time, that you're aware of, someone has cheated death subconsciously.";

 begintalknode 24;
	state = 1;
	nextstate = -1;
	condition = get_flag(10,6) == 2;
	question = "Show me what you've created over the years.";
	text1 = "_Now, unless you want something else, I need to get back to work_";
	code = begin_shop_mode("Havelock's Emporium","Havelock has accidentally created several powerful items in the course of years. Now that you've shown him he's dead, he has lowered his prices a bit.",9,3,-1);
 break;

 begintalknode 25;
	state = 11;
	nextstate = -1;
	condition = has_special_item(6);
	question = "You got yourself a deal Havelock.";
	text1 = "Havelock teaches you about nature lore. Then he takes the bat head and disappears into his backroom. He comes back with a few items. _Here take them!_";
	action = SET_SDF 1 27 3;
	code = take_special_item(6);
		reward_give(240);
		reward_give(462);
		j = char_with_highest_skill(16);
		alter_stat(j,16,3);
 break;
